//
//  JSMStrategyContinentCollectionViewCell.m
//  TakeYouTourTogether
//
//  Created by king on 15/12/5.
//  Copyright © 2015年 king. All rights reserved.
//

#import "JSMStrategyContinentCollectionViewCell.h"

@implementation JSMStrategyContinentCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createStrategyContinentCollectionViewCell];
    }
    return self;
}

- (void)createStrategyContinentCollectionViewCell {
    self.myImageView = [[BaseImageView alloc] init];
    self.myImageView.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.myImageView];
    
    self.myButton = [BaseButton buttonWithType:UIButtonTypeCustom];
    self.myButton.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.myButton];
    self.myButton.selected = NO;
//    [self.myButton addTarget:self action:@selector(imageChange:) forControlEvents:UIControlEventTouchUpInside];
    
    self.myLabel = [[UILabel alloc] init];
    self.myLabel.backgroundColor = [UIColor clearColor];
    self.myLabel.textColor = [UIColor grayColor];
    self.myLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.myLabel];
    self.myLabel.highlightedTextColor = [UIColor redColor];
    
    
    //修改button图片
    [self uptouchcell];
    
}

- (void)layoutSubviews {
    self.myImageView.frame = CGRectMake(TABLEVIEWCELL_WIDTH/4, (TABLEVIEWCELL_HEIGHT-TABLEVIEWCELL_WIDTH/2-50), TABLEVIEWCELL_WIDTH/2, TABLEVIEWCELL_WIDTH/2);
    self.myLabel.frame = CGRectMake(0, TABLEVIEWCELL_HEIGHT-40, TABLEVIEWCELL_WIDTH, 40);
    
    
    NSLog(@"%ld",self.number);
    if (self.number == self.nownumber) {
        [self touchcell];
    }else{
        [self uptouchcell];
    }
    
    
}
- (void)touchcell{
    [self.myImageView setImage:[UIImage imageNamed:Trendsite_Selected_Image]];
//    [self.myButton setImage:[UIImage imageNamed:Trendsite_Selected_Image] forState:UIControlStateNormal];
}
- (void)uptouchcell{
    [self.myImageView setImage:[UIImage imageNamed:Trendsite_Image]];
//    [self.myButton setImage:[UIImage imageNamed:Trendsite_Image] forState:UIControlStateNormal];

}
- (void)setStr:(NSString *)str {
    if (_str != str) {
        _str = str;
    }
    self.myLabel.text = str;
}

@end
